package cn.android.support.v7.lib.sin.crown.base;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.View;

import cn.android.support.v7.lib.sin.crown.utils.ProportionUtils;

/**
 * Created by 彭治铭 on 2017/9/29.
 */

public class BaseView extends View {
    public BaseView(Context context) {
        super(context);
        init();
    }

    public BaseView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    protected Paint paint;
    protected TextPaint textPaint;

    private void init() {
        paint = new Paint();
        paint.setAntiAlias(true);
        paint.setDither(true);
        paint.setTextAlign(Paint.Align.CENTER);
        textPaint = new TextPaint();
        textPaint.setAntiAlias(true);
        textPaint.setDither(true);
        textPaint.setTextAlign(Paint.Align.CENTER);
        setLayerType(View.LAYER_TYPE_HARDWARE, paint);
    }

    protected int TextSize, textColor;

    //在子类中调用，true 主。false 次
    protected void setMainOrSub(boolean mainOrSub) {
        if (mainOrSub) {
            TextSize = ProportionUtils.getInstance().adapterInt(38);
            textColor = Color.parseColor("#444444");
        } else {
            TextSize = ProportionUtils.getInstance().adapterInt(32);
            textColor = Color.parseColor("#888888");
        }
        textPaint.setTextSize(TextSize);
        textPaint.setColor(textColor);
    }

}
